#!/usr/bin/env python
# -*- coding:utf-8 -*-
# @Time      :2021/7/16 13:56
# @Author    :cjw
from sqlalchemy import Boolean, Column, Integer, String
from sqlalchemy.orm import relationship

from app.db.session import Base


class User(Base):
    """用户表"""
    __tablename__ = 'users'

    id = Column(Integer, primary_key=True, index=True)
    full_name = Column(String(255), index=True, comment='全名')
    email = Column(String(255), unique=True, index=True, comment='邮箱')
    hashed_password = Column(String(255), comment='哈希密码')
    is_active = Column(Boolean, default=True, comment='是否是活跃用户，默认是')
    is_superuser = Column(Boolean, default=False, comment='是否是超级用户，默认否')

    items = relationship('Item', back_populates='owner')

    def __repr__(self):
        return f'User({self.email})'
